(* Since BigNumbers raises exponentially, just use iterative calls for power *)

fun Two_to_Power_of(n) = 
  let
    fun power(x, n) = 
      if n = 1 then x
	  else
	    if n mod 2 = 0 then power(x*x, n div 2)
	    else x * power(x*x, n div 2);
  in
    power(2, n)
  end;
  
fun Sum_Digits(k) =
  let 
    fun f(0, sum) = sum
	  | f(k, sum) = f(k div 10, sum + k mod 10);
  in
    f(k, 0)
  end;
  
Sum_Digits(Two_to_Power_of(1000));
	   
